<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('材料申请单列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li hidden>
                                <label>材料类型：</label>
                                <input type="text" name="matTypes"/>
                            </li>
                            <li hidden>
                                <label>材料分类：</label>
                                <input type="text" name="matClassifications"/>
                            </li>
                            <li hidden>
                                <label>材料数据：</label>
                                <input type="text" name="matDatas"/>
                            </li>
                            <li hidden>
                                <label>材料详情：</label>
                                <input type="text" name="matDetailss"/>
                            </li>
                            <li hidden>
                                <label>材料数量：</label>
                                <input type="text" name="matNumbers"/>
                            </li>
                            <li hidden>
                                <label>申请人：</label>
                                <input type="text" name="mPeoples"/>
                            </li>
                            <li hidden>
                                <label>状态：</label>
                                <select name="mStatus">
                                    <option value="">所有</option>
                                </select>
                            </li>
                            <li>
                                <label>项目名称：</label>
                                <input type="text" name="pName"/>
                            </li>
                            <li class="select-time">
                                <label>创建时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginPTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endPTime]"/>
                            </li>
                            <li hidden>
                                <label>审批意见：</label>
                                <input type="text" name="mOpinions"/>
                            </li>
                            <li hidden>
                                <label>项目外键：</label>
                                <input type="text" name="mId"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

<!--            <div class="btn-group-sm" id="toolbar" role="group">-->
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ruoyi:requisitiones:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="ruoyi:requisitiones:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ruoyi:requisitiones:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ruoyi:requisitiones:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
<!--            </div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ruoyi:requisitiones:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ruoyi:requisitiones:remove')}]];
        var creadFlag = [[${@permission.hasPermi('ruoyi:requisitiones:add')}]];
        var prefixs = ctx + "ruoyi/requisitiones";
        var prefix = ctx + "system/building";
        //审批状态字典
        var mStatus = [[${@dict.getType('mate_status')}]];
        $(function(){
            var options = {
                url: prefix + "/list",
                createUrl: prefixs + "/add/{id}",
                exportUrl: prefix + "/export",
                removeUrl: prefixs + "/remove",
                updateUrl: prefixs + "/edit/{id}",
                modalName:"",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                detailView: true,
                onExpandRow: function (index, row, $building) {
                    initChildTable(index, row, $building);
                },

                columns: [{
                    checkbox: true
                },
                    {
                        field: 'pId',
                        title: '项目id',
                        visible: false
                    },
                    {
                        field: 'pName',
                        title: '项目名称'
                    },
                    {
                        field: 'pTime',
                        title: '项目日期'
                    },
                    {
                        field: 'pFounder',
                        title: '项目经理'
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success ' + creadFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.pId + '\')"><i class="fa fa-add"></i>添加</a> ');
                            return actions.join('');
                        }
                    }
                ]
            };
            $.table.init(options);
        });
        initChildTable = function (index, row, $building) {
            var childTable = $building.html('<table style="table-layout:fixed"></table>').find('table');
            $(childTable).bootstrapTable({
                url: prefixs  + "/lists",
                method: 'post',
                sidePagination: "server",
                contentType: "application/x-www-form-urlencoded",
                queryParams: {
                    mId:row.pId
                },
                columns: [
                    // {
                    //     checkbox: true
                    // },
                    {
                        field: 'mMid',
                        title: '主键id',
                        visible: false
                    },
                    {
                        field: 'matTypes',
                        title: '材料类型'
                    },
                    {
                        field: 'matClassifications',
                        title: '材料分类'
                    },
                    {
                        field: 'matDatas',
                        title: '材料数据'
                    },
                    {
                        field: 'matDetailss',
                        title: '材料详情'
                    },
                    {
                        field: 'matNumbers',
                        title: '材料数量'
                    },
                    {
                        field: 'mPeoples',
                        title: '申请人'
                    },
                    {
                        field: 'mStatus',
                        title: '状态',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(mStatus, value);
                        }
                    },
                    {
                        field: 'mMtime',
                        title: '创建时间'
                    },
                    {
                        field: 'mOpinions',
                        title: '审批意见'
                    },
                    {
                        field: 'mId',
                        title: '项目外键',
                        visible: false
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            if (row.mStatus==0){
                                actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="submitApply(\'' + row.mMid + '\')"><i class="fa fa-user"></i> 提交</a> ');
                                //actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.mMid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mMid + '\')"><i class="fa fa-remove"></i>删除</a>');
                            }else if (row.mStatus==1){
                                actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="revocation(\'' + row.mMid + '\')"><i class="fa fa-user"></i> 撤销</a> ');
                            }else if (row.mStatus==3){
                                actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="submitApply(\'' + row.mMid + '\')"><i class="fa fa-user"></i> 重新提交</a> ');
                                //actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.mMid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mMid + '\')"><i class="fa fa-remove"></i>删除</a>');
                            }
                            return actions.join('');
                        }
                    }
                ]
            });
        };
        function submitApply(mMid) {

            $.modal.confirm("确认要提交申请吗?", function() {
                var url = prefixs + "/submitApply";
                var data = { "mMid": mMid };
                $.operate.submit(url, "post", "json", data);
            });
        }
        function revocation(mMid) {

            $.modal.confirm("确认要撤销申请吗?", function() {
                var url = prefixs + "/revocation";
                var data = { "mMid": mMid };
                $.operate.submit(url, "post", "json", data);
            });
        }


        // $(function() {
        //     var options = {
        //         url: prefix + "/list",
        //         createUrl: prefix + "/add",
        //         updateUrl: prefix + "/edit/{id}",
        //         removeUrl: prefix + "/remove",
        //         exportUrl: prefix + "/export",
        //         modalName: "材料申请单",
        //         columns: [{
        //             checkbox: true
        //         },
        //         {
        //             field: 'mMid',
        //             title: '主键id',
        //             visible: false
        //         },
        //         {
        //             field: 'matTypes',
        //             title: '材料类型'
        //         },
        //         {
        //             field: 'matClassifications',
        //             title: '材料分类'
        //         },
        //         {
        //             field: 'matDatas',
        //             title: '材料数据'
        //         },
        //         {
        //             field: 'matDetailss',
        //             title: '材料详情'
        //         },
        //         {
        //             field: 'matNumbers',
        //             title: '材料数量'
        //         },
        //         {
        //             field: 'mPeoples',
        //             title: '申请人'
        //         },
        //         {
        //             field: 'mStatus',
        //             title: '状态'
        //         },
        //         {
        //             field: 'mMtime',
        //             title: '创建时间'
        //         },
        //         {
        //             field: 'mOpinions',
        //             title: '审批意见'
        //         },
        //         {
        //             title: '操作',
        //             align: 'center',
        //             formatter: function(value, row, index) {
        //                 var actions = [];
        //                 actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.mMid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
        //                 actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mMid + '\')"><i class="fa fa-remove"></i>删除</a>');
        //                 return actions.join('');
        //             }
        //         }]
        //     };
        //     $.table.init(options);
        // });
    </script>
</body>
</html>